const flattening = <T extends { _id: string }>(array: Array<T>) => {
  array.reduce<{ [name: string]: T }>((pre, item) => {
    pre[item._id] = item;
    return pre;
  }, {});
};

const threeDimensional = <T>(object: { [name: string]: T }) => {
  return Object.keys(object).map((item) => object[item]);
};

export { threeDimensional, flattening };
